import { ResponseAdminPermissionListItemType } from '@/services/apis/admin/permission';
import { ResponseBodyType, ResponseDetailType } from '@/services/apis/types';
import { success } from '../common';
import { Request, Response } from 'express';

const list: ResponseAdminPermissionListItemType[] = [
  {
    id: 1,
    menuId: 2,
    menuName: '账号管理',
    apis: [
      {
        permissionId: 1,
        id: 1,
        path: '/admin/user/list',
        key: 'adminUser::list',
        name: '账号列表',
      },
      {
        permissionId: 1,
        id: 3,
        path: '/admin/user/detail',
        key: 'adminUser::detail',
        name: '账号详情',
      },
      {
        permissionId: 1,
        id: 40,
        path: '/admin/role/all',
        key: 'adminRole::all',
        name: '角色全部',
      },
    ],
    key: 'AdminUserView',
    name: '账号查看',
    describe: '账号管理查看',
    type: 'view',
    typeText: '查看',
    enabled: false,
    createTime: '2022-08-07 10:42:31',
    modifyTime: '2022-08-07 10:42:31',
  },
  {
    id: 2,
    menuId: 2,
    menuName: '账号管理',
    apis: [
      {
        permissionId: 2,
        id: 2,
        path: '/admin/user/add',
        key: 'adminUser::add',
        name: '账号创建',
      },
      {
        permissionId: 2,
        id: 4,
        path: '/admin/user/edit',
        key: 'adminUser::edit',
        name: '账号编辑',
      },
      {
        permissionId: 2,
        id: 5,
        path: '/admin/user/enable',
        key: 'adminUser::enable',
        name: '账号启用禁用',
      },
      {
        permissionId: 2,
        id: 7,
        path: '/admin/user/bindRoles',
        key: 'adminUser::bindRoles',
        name: '账号绑定角色',
      },
    ],
    key: 'AdminUserEdit',
    name: '账号编辑',
    describe: '账号管理编辑',
    type: 'edit',
    typeText: '编辑',
    enabled: true,
    createTime: '2022-08-06 20:20:58',
    modifyTime: '2022-08-06 20:20:58',
  },
  {
    id: 3,
    menuId: 2,
    menuName: '账号管理',
    apis: [
      {
        permissionId: 3,
        id: 6,
        path: '/admin/user/delete',
        key: 'adminUser::delete',
        name: '账号删除',
      },
    ],
    key: 'AdminUserDelete',
    name: '账号删除',
    describe: '账号管理删除',
    type: 'delete',
    typeText: '删除',
    enabled: true,
    createTime: '2022-08-06 20:20:58',
    modifyTime: '2022-08-06 20:20:58',
  },
  {
    id: 4,
    menuId: 3,
    menuName: '角色管理',
    apis: [
      {
        permissionId: 4,
        id: 8,
        path: '/admin/role/list',
        key: 'adminRole::list',
        name: '角色列表',
      },
      {
        permissionId: 4,
        id: 10,
        path: '/admin/role/detail',
        key: 'adminRole::detail',
        name: '角色详情',
      },
      {
        permissionId: 4,
        id: 15,
        path: '/admin/role/permissions',
        key: 'adminRole::permissions',
        name: '角色权限列表',
      },
      {
        permissionId: 4,
        id: 40,
        path: '/admin/role/all',
        key: 'adminRole::all',
        name: '角色全部',
      },
      {
        permissionId: 4,
        id: 41,
        path: '/admin/menu/mode',
        key: 'adminMenu::mode',
        name: '菜单页面权限列表',
      },
    ],
    key: 'AdminRoleView',
    name: '角色查看',
    describe: '角色管理查看',
    type: 'view',
    typeText: '查看',
    enabled: true,
    createTime: '2022-08-06 20:21:52',
    modifyTime: '2022-08-06 20:21:52',
  },
  {
    id: 5,
    menuId: 3,
    menuName: '角色管理',
    apis: [
      {
        permissionId: 5,
        id: 9,
        path: '/admin/role/add',
        key: 'adminRole::add',
        name: '角色创建',
      },
      {
        permissionId: 5,
        id: 11,
        path: '/admin/role/edit',
        key: 'adminRole::edit',
        name: '角色编辑',
      },
      {
        permissionId: 5,
        id: 12,
        path: '/admin/role/enable',
        key: 'adminRole::enable',
        name: '角色禁用启用',
      },
      {
        permissionId: 5,
        id: 14,
        path: '/admin/role/bindPermissions',
        key: 'adminRole::bindPermissions',
        name: '角色绑定权限',
      },
    ],
    key: 'AdminRoleEdit',
    name: '角色编辑',
    describe: '角色管理编辑',
    type: 'edit',
    typeText: '编辑',
    enabled: true,
    createTime: '2022-08-06 20:21:52',
    modifyTime: '2022-08-06 20:21:52',
  },
  {
    id: 6,
    menuId: 3,
    menuName: '角色管理',
    apis: [
      {
        permissionId: 6,
        id: 13,
        path: '/admin/role/delete',
        key: 'adminRole::delete',
        name: '角色删除',
      },
    ],
    key: 'AdminRoleDelete',
    name: '角色删除',
    describe: '角色管理删除',
    type: 'delete',
    typeText: '删除',
    enabled: true,
    createTime: '2022-08-06 20:21:52',
    modifyTime: '2022-08-06 20:21:52',
  },
  {
    id: 7,
    menuId: 4,
    menuName: '菜单管理',
    apis: [
      {
        permissionId: 7,
        id: 16,
        path: '/admin/menu/tree',
        key: 'adminMenu::tree',
        name: '菜单树',
      },
      {
        permissionId: 7,
        id: 17,
        path: '/admin/menu/list',
        key: 'adminMenu::list',
        name: '菜单列表',
      },
      {
        permissionId: 7,
        id: 19,
        path: '/admin/menu/detail',
        key: 'adminMenu::detail',
        name: '菜单详情',
      },
      {
        permissionId: 7,
        id: 23,
        path: '/admin/menu/permissions',
        key: 'adminMenu::permissions',
        name: '菜单权限',
      },
      {
        permissionId: 7,
        id: 24,
        path: '/admin/menu/pages',
        key: 'adminMenu::pages',
        name: '菜单页面列表',
      },
      {
        permissionId: 7,
        id: 41,
        path: '/admin/menu/mode',
        key: 'adminMenu::mode',
        name: '菜单页面权限列表',
      },
    ],
    key: 'AdminMenuView',
    name: '菜单查看',
    describe: '菜单管理查看',
    type: 'view',
    typeText: '查看',
    enabled: true,
    createTime: '2022-08-06 20:22:07',
    modifyTime: '2022-08-06 20:22:07',
  },
  {
    id: 8,
    menuId: 4,
    menuName: '菜单管理',
    apis: [
      {
        permissionId: 8,
        id: 18,
        path: '/admin/menu/add',
        key: 'adminMenu::add',
        name: '菜单创建',
      },
      {
        permissionId: 8,
        id: 20,
        path: '/admin/menu/edit',
        key: 'adminMenu::edit',
        name: '菜单编辑',
      },
      {
        permissionId: 8,
        id: 21,
        path: '/admin/menu/enable',
        key: 'adminMenu::enable',
        name: '菜单禁用启用',
      },
      {
        permissionId: 8,
        id: 31,
        path: '/admin/permission/addMenuPermissions',
        key: 'adminPermission::addMenuPermissions',
        name: '权限指定菜单批量创建权限',
      },
    ],
    key: 'AdminMenuEdit',
    name: '菜单编辑',
    describe: '菜单管理编辑',
    type: 'edit',
    typeText: '编辑',
    enabled: true,
    createTime: '2022-08-06 20:22:07',
    modifyTime: '2022-08-06 20:22:07',
  },
  {
    id: 9,
    menuId: 4,
    menuName: '菜单管理',
    apis: [
      {
        permissionId: 9,
        id: 22,
        path: '/admin/menu/delete',
        key: 'adminMenu::delete',
        name: '菜单删除',
      },
    ],
    key: 'AdminMenuDelete',
    name: '菜单删除',
    describe: '菜单管理删除',
    type: 'delete',
    typeText: '删除',
    enabled: true,
    createTime: '2022-08-06 20:22:07',
    modifyTime: '2022-08-06 20:22:07',
  },
  {
    id: 10,
    menuId: 5,
    menuName: '权限管理',
    apis: [
      {
        permissionId: 10,
        id: 25,
        path: '/admin/permission/list',
        key: 'adminPermission::list',
        name: '权限列表',
      },
      {
        permissionId: 10,
        id: 27,
        path: '/admin/permission/detail',
        key: 'adminPermission::detail',
        name: '权限详情',
      },
    ],
    key: 'AdminPermissionView',
    name: '权限查看',
    describe: '权限管理查看',
    type: 'view',
    typeText: '查看',
    enabled: true,
    createTime: '2022-08-06 20:22:17',
    modifyTime: '2022-08-06 20:22:17',
  },
];
const listData: ResponseBodyType = {
  code: 0,
  type: 'SUCCESS',
  message: '操作成功',
  data: {
    pageNum: 1,
    pageSize: 10,
    total: 15,
    list: list,
  },
};

const detail: ResponseDetailType = {
  code: 0,
  type: 'SUCCESS',
  message: '操作成功',
  data: {
    id: 1,
    menuId: 2,
    menuName: '账号管理',
    menuPath: '/admin/user',
    apis: [
      {
        permissionId: 1,
        id: 1,
        path: '/admin/user/list',
        key: 'adminUser::list',
        name: '账号列表',
      },
      {
        permissionId: 1,
        id: 3,
        path: '/admin/user/detail',
        key: 'adminUser::detail',
        name: '账号详情',
      },
      { permissionId: 1, id: 40, path: '/admin/role/all', key: 'adminRole::all', name: '角色全部' },
    ],
    key: 'AdminUserView',
    name: '账号查看',
    describe: '账号管理查看',
    type: 'view',
    typeText: '查看',
    enabled: true,
    createTime: '2022-08-07 10:42:31',
    modifyTime: '2022-08-07 10:42:31',
  },
};

export default {
  'POST /api/admin/permission/menu': success,
  'POST /api/admin/permission/list': (req: Request, res: Response) => {
    listData.data.pageNum = req.body.pageNum;
    listData.data.pageSize = req.body.pageSize;
    res.json(listData);
  },
  'POST /api/admin/permission/add': success,
  'POST /api/admin/permission/detail': detail,
  'POST /api/admin/permission/edit': success,
  'POST /api/admin/permission/delete': success,
  'POST /api/admin/permission/enable': success,
  'POST /api/admin/permission/unbind': success,
  'POST /api/admin/permission/bind': success,
};
